package ${bizImpPack};

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ${bizPack}.${className}Biz;
import ${daoPack}.${className}Dao;
import ${entityPack}.${className};
import com.sinosoft.system.util.page.Pagenation;

@Service
@Transactional
public class ${className}BizImp implements ${className}Biz{

	private static Logger log = Logger.getLogger(${className}BizImp.class);
	
	@Autowired
	private ${className}Dao ${instName}Dao;
	
	@Override
	public int insert${className}(${className} ${instName}) {
		log.info("新增${className}数据"+${instName}.toString());
		return ${instName}Dao.insert${className}(${instName});
	}

	@Override
	public int update${className}(${className} ${instName}) {
		log.info("更新${className}数据"+${instName}.toString());
		return ${instName}Dao.update${className}(${instName});
	}

	@Override
	public int delete${className}(int id) {
		log.info("删除${className}数据 id="+id);
		return ${instName}Dao.delete${className}(id);
	}

	@Override
	public ${className} select${className}(int id) {
		log.info("根据ID查询${className}数据 id="+id);
		return ${instName}Dao.select${className}(id);
	}

	@Override
	public ${className} select${className}(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询${className}数据 ");
		return ${instName}Dao.select${className}(queryKeys, queryValues);
	}

	@Override
	public int selectCount${className}() {
		log.info("查询${className}数据 总数量");
		return ${instName}Dao.selectCount${className}();
	}

	@Override
	public int selectCount${className}(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询${className}数据 总数量"+queryKeys.toString());
		return ${instName}Dao.selectCount${className}(queryKeys, queryValues);
	}

	@Override
	public List<${className}> selectLimit${className}(int start, int size) {
		log.info("查询${className}数据 limit数量:start="+start+",size="+size);
		return ${instName}Dao.selectLimit${className}(start, size);
	}

	@Override
	public List<${className}> selectLimit${className}(List<String> queryKeys,List<Object> queryValues,int start, int size) {
		log.info("条件查询${className}数据数量");
		return ${instName}Dao.selectLimit${className}(queryKeys, queryValues, start,  size);
	}

	@Override
	public List<${className}> selectAll${className}() {
		log.info("查询所有${className}数据");
		return ${instName}Dao.selectAll${className}();
	}

	@Override
	public List<${className}> selectAll${className}(List<String> queryKeys,List<Object> queryValues) {
		log.info("条件查询所有${className}数据");
		return ${instName}Dao.selectAll${className}(queryKeys, queryValues);
	}

	@Override
	public Pagenation selectPage${className}(Pagenation page) {
		log.info("分页查询所有${className}数据");
		int start =	page.getStartRow();
		int size = page.getPageSize();
		List<${className}> rows = ${instName}Dao.selectLimit${className}(page.getQueryKeys(), page.getQueryValues(),start,size);
		int total = ${instName}Dao.selectCount${className}(page.getQueryKeys(), page.getQueryValues());
		page.setTotal(total);
		page.setRows(rows);
		return page;
	}

	public ${className}Dao get${className}Dao() {
		return ${instName}Dao;
	}

	public void set${className}Dao(${className}Dao ${instName}Dao) {
		this.${instName}Dao = ${instName}Dao;
	}

}
